﻿#include<iostream>
using namespace std;

const int N = 40;

int n, ans[N], arr[N], pos;

void build(int p)
{
	if (p > n)return;
	build(p << 1);
	build(p << 1 | 1);
	ans[p] = arr[++pos];
}

int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> arr[i];
	build(1);
	cout << ans[1];
	for (int i = 2; i <= n; i++)cout << " " << ans[i];
	return 0;
}